package com.Maykk.Demo01;

import java.util.LinkedHashSet;

/**
 * @ClassName: Demo06
 * @Description: TODO LinkedHashSet 练习
 * LinkedHashSet 读写有序，其他与 HashSet 无太大差别
 * 没有带索引的方法，不能使用普通 for 循环遍历，只能使用迭代器或者增强 for
 * @Author: MaykkStar@163.com
 */
public class Demo06 {
    public static void main(String[] args) {
        LinkedHashSet<Student> stuLHS = new LinkedHashSet<>();
        stuLHS.add(new Student("Lucy", 19));
        stuLHS.add(new Student("Andy", 18));
        stuLHS.add(new Student("Maya", 16));
        stuLHS.add(new Student("LiHua", 15));
        stuLHS.add(new Student("Lucy", 19));
        for (Student stu : stuLHS) {
            System.out.println(stu);
        }
    }
}
